<?php
session_start();
$name = $_SESSION["adminname"];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="description" content="xxxxx">
    <meta name="author" content="xxxxx">
    <meta name="keyword" content="xxxxx">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>图书在馆状态</title>
    <!-- start: Css -->
    <link rel="stylesheet" type="text/css" href="asset/css/bootstrap.min.css">
    <!-- plugins -->
    <link rel="stylesheet" type="text/css" href="asset/css/plugins/font-awesome.min.css"/>
    <link rel="stylesheet" type="text/css" href="asset/css/plugins/simple-line-icons.css"/>
    <link rel="stylesheet" type="text/css" href="asset/css/plugins/animate.min.css"/>
    <link rel="stylesheet" type="text/css" href="asset/css/plugins/fullcalendar.min.css"/>
    <link href="asset/css/style.css" rel="stylesheet">
    <!-- end: Css -->
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="asset/js/html5shiv.min.js"></script>
    <script src="asset/js/respond.min.js"></script>
    <![endif]-->
</head>

<body id="mimin" class="dashboard">
<!-- start: Header -->
<nav class="navbar navbar-default header navbar-fixed-top">
    <div class="col-md-12 nav-wrapper">
        <div class="navbar-header" style="width:100%;">
            <div class="opener-left-menu is-open"> <span class="top"></span> <span class="middle"></span> <span class="bottom"></span> </div>
            <a href="index_normal.php" class="navbar-brand"> <b>图书管理系统</b> </a>
            <ul class="nav navbar-nav navbar-right user-nav">
                <li class="user-name"><span><?php echo $name?></span></li>
                <li class="dropdown avatar-dropdown"> <img src="asset/img/avatar.jpg" class="img-circle avatar" alt="user name" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"/>
                    <ul class="dropdown-menu user-dropdown">
                        <li><a href="index.html"><span class="fa fa-power-off"></span> 退出登录</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>
<!-- end: Header -->
<div class="container-fluid mimin-wrapper">
    <!-- start:Left Menu -->
    <div id="left-menu">
        <div class="sub-left-menu scroll">
            <ul class="nav nav-list">
                <li>
                    <div class="left-bg"></div>
                </li>
                <li class="ripple"> <a  class="tree-toggle nav-header" id="left-menu-1"><span class="fa-home fa"></span> 首页 <span class="fa-angle-right fa right-arrow text-right"></span> </a>
                    <ul class="nav nav-list tree" >
                        <li><a href="index_normal.php">首页</a></li>
                    </ul>
                </li>
                <li class="ripple active"> <a class="tree-toggle nav-header"  id="left-menu-2"> <span class="fa-diamond fa"></span> 图书管理 <span class="fa-angle-right fa right-arrow text-right"></span> </a>
                    <ul class="nav nav-list tree">
                        <li><a href="bookstate_super.php">图书在馆状态</a></li>
                        <li><a href="bookbo_super.php">图书借阅记录</a></li>
                        <li><a href="bookinser_super.php">上架新书</a></li>
                        <li><a href="bookdelete_super.php">下架图书</a></li>
                        <li><a href="bookda_super.php">图书损失记录</a></li>
                        <li><a href="fine_super.php">记录罚款信息</a></li>
                    </ul>
                </li>
                <li class=" ripple"> <a class="tree-toggle nav-header"  id="left-menu-3"><span class="fa fa-check-square-o"></span> 用户管理 <span class="fa-angle-right fa right-arrow text-right"></span> </a>
                    <ul class="nav nav-list tree" >
                        <li><a href="readerbor_super.php">用户借阅记录</a></li>
                        <li><a href="readerfine_super.php">罚款记录</a></li>
                        <li><a href="readerselect_super.php">查询用户</a></li>
                        <li><a href="readerinsert_super.php">新增用户</a></li>
                        <li><a href="readerdelete_super.php">删除用户</a></li>
                        <li><a href="normalselect_super.php">查询管理员</a></li>
                        <li><a href="normalinsert_super.php">新增管理员</a></li>
                        <li><a href="normaldelete_super.php">删除管理员</a></li>
                    </ul>
                </li>
                <li class=" ripple"> <a class="tree-toggle nav-header"  id="left-menu-3"><span class="fa fa-check-square-o"></span> 我的 <span class="fa-angle-right fa right-arrow text-right"></span> </a>
                    <ul class="nav nav-list tree" >
                        <li><a href="pwd_super.php">修改密码</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>

    <!-- end: Left Menu -->

    <!-- start: content -->
    <div id="content">
        <div class="panel">
            <div class="panel-body">
                <div class="col-md-12">
                    <h3 class="animated fadeInLeft">图书在馆状态</h3>
                    <p class="animated fadeInDown"> 图书管理 <span class="fa-angle-right fa"></span> 图书在馆状态 </p>
                </div>
            </div>
        </div>
        <div class="col-md-12 padding-0 form-element">
            <div class="col-md-12">
                <div class="panel form-element-padding">
                    <div class="panel-heading">
                        <h4>查询条件</h4>
                    </div>
                    <form method="post" action="">
                    <div class="panel-body" style="padding-bottom:30px;">
                        <div class="form-group">
                            <label class="col-sm-1 control-label text-right">编号</label>
                            <div class="col-sm-2">
                                <input type="text" class="form-control" name="bookNo">
                            </div>
                            <label class="col-sm-1 control-label text-right">书名</label>
                            <div class="col-sm-2">
                                <input type="text" class="form-control" name="bookName">
                            </div>
                        </div>
                        <div class="col-sm-2">
                            <input class="submit btn btn-danger" type="submit" value="提交">
                        </div>
                    </div>
                    </form>
                </div>
                <div class="panel">
                    <div class="panel-heading">
                        <h3>图书状态</h3>
                    </div>
                    <div class="panel-body">
                        <div class="responsive-table">
                            <div id="datatables-example_wrapper" class="dataTables_wrapper form-inline dt-bootstrap no-footer">
                                <div class="row">
                                    <div class="col-sm-12">
                                        <table class="table table-striped table-bordered dataTable no-footer" width="100%" cellspacing="0"  style="width: 100%;">
                                            <thead>
                                            <tr role="row">
                                                <th class="sorting_asc"style="width: 60px;">编号</th>
                                                <th class="sorting" style="width: 60px;">书名</th>
                                                <th class="sorting" style="width: 60px;">状态</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            <?php
                                            $mysqli = mysqli_connect("localhost", "root", "123456", "library");
                                            mysqli_query($mysqli,"SET NAMES 'utf8'");
                                            $bookNo=$_POST['bookNo'];
                                            $bookName = $_POST['bookName'];
                                            if ($bookNo == null && $bookName!=null){
                                                $sql = "SELECT * FROM book where bookName like '%$bookName%'";
                                            }
                                            elseif ($bookNo != null && $bookName == null){
                                                $sql = "SELECT * FROM book where bookNo='$bookNo'";
                                            }
                                            elseif ($bookNo != null && $bookName != null){
                                                $sql = "SELECT * FROM book where bookNo='$bookNo' and bookName like '%$bookName%'";
                                            }
                                            else{
                                                $sql = "doublenull";
                                            }

                                            if ($sql=="doublenull"){
                                                $sql = "SELECT * FROM book ";
                                                $rowsult = $mysqli->query($sql);
                                                if ($rowsult->num_rows > 0) {
                                                    // 输出数据
                                                    $i = 0;
                                                    while ($row = $rowsult->fetch_assoc()) {
                                                        $i++;
                                                        if ($i % 2 == 1)
                                                            echo "\n<tr role=\"row\" class=\"odd\">";
                                                        else
                                                            echo "\n<tr role=\"row\" class=\"even\">";

                                                        echo "\n<td> ", $row['bookNo'], "</td>";
                                                        echo "\n<td> ", $row['bookName'], "</td>";
                                                        echo "\n<td> ", $row['inLibStatus'], "</td>";
                                                        echo "\n</tr>";
                                                    }}
                                            }
                                            else{
                                                $rowsult = $mysqli->query($sql);


                                                if ($rowsult->num_rows > 0) {
                                                    // 输出数据
                                                    $i = 0;
                                                    while ($row = $rowsult->fetch_assoc()) {
                                                        $i++;
                                                        if ($i % 2 == 1)
                                                            echo "\n<tr role=\"row\" class=\"odd\">";
                                                        else
                                                            echo "\n<tr role=\"row\" class=\"even\">";

                                                        echo "\n<td> ", $row['bookNo'], "</td>";
                                                        echo "\n<td> ", $row['bookName'], "</td>";
                                                        echo "\n<td> ", $row['inLibStatus'], "</td>";
                                                        echo "\n</tr>";
                                                    }
                                                } else {
                                                    echo "无结果";
                                                }
                                            }
                                            // 释放结果集
                                            mysqli_free_result($rowsult);

                                            $mysqli->close();
                                            ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <!-- end: content -->
</div>
<!-- start: Javascript -->
<script src="asset/js/jquery.min.js"></script>
<script src="asset/js/jquery.ui.min.js"></script>
<script src="asset/js/bootstrap.min.js"></script>
<!-- plugins -->
<script src="asset/js/plugins/jquery.nicescroll.js"></script>
<!-- custom -->
<script src="asset/js/main.js"></script>
<!-- end: Javascript -->
<script>
    $("#left-menu-2").click() ;
</script>
</body>
</html>